const LocalSetting = (function () {

    var isFunction = function (value) {
        return Object.prototype.toString.call(value) === '[object Function]'
    };

    var _local = function (key, value) {
        if (!isFunction(localStorage.setItem)) return '';
        if (value === undefined) {

            return localStorage.getItem(key);
        }

        localStorage.setItem(key, value);
        return localStorage.getItem(key);
    };

    var setting = function (key, value) {

        var __local = _local('__Local__Setting') ? JSON.parse(_local('__Local__Setting')) : {};
        if (value === undefined) {
            return __local[key];
        }

        __local[key] = value;
        _local('__Local__Setting', JSON.stringify(__local));
        return __local;
    };

    return {
        setting,
    };
})();
export default LocalSetting;
